<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
           请选择兴趣爱好
           <div>
               <input type="checkbox" value="吃饭" v-model="hobby" />吃饭
               <input type="checkbox" value="睡觉" v-model="hobby" />睡觉
               <input type="checkbox" value="豆豆" v-model="hobby" />豆豆
           </div>
           选中的结果为{{hobby}}
           <button @click="add">新增</button>
        
         
    </div>
</body>
<script>
    new  Vue({
        el:"#app",
        data:{
            hobby:[]
        },
        methods:{
            add(){
                if(this.hobby.length){
                        alert("选择的兴趣爱好为"+this.hobby);
                }else{
                   alert("必须选择一个兴趣爱好") 
                }
            }
        }
    })


</script>
</html>